
#include <iostream>
#include <fstream>
#include <vector>
#include <string>

#include <fmt/core.h>
#include "scripts.h"

using namespace std;
using fmt::format;

int main() {
    TopoScript topo;
    string cmd, filename;
    vector<ofstream> fds(topo.nodes.size());
    int i=0;

    // 创建文件
    for (auto &node : topo.nodes) {
        filename = format(LINK_FILE, node.first);
        fds[i++].open(filename, ios::out|ios::trunc);
    }

    while(topo.slot <= MAX_SLOT) {
        topo.update_link();
        i = 0;
        for(auto &str : topo.scripts) {
            cmd = format("{}:{}\n", topo.slot, str.second);
            fds[i++] << cmd;
        }
        topo.slot++;
    }

    for (auto &fd : fds)
        fd.close();

    topo.veth_pair_script();
    topo.ovs_init_script();

    return 0;
}